﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HammerMUD.Accounts;
using HammerMUD.Races;
using HammerMUD.Professions;
using HammerMUD.Rooms;
using HammerMUD.Items;
using HammerMUD.System;
using System.Xml.Serialization;
using HammerMUD.Admin;

namespace HammerMUD.Characters
{
    public class Character
    {
        private String name;
        private Account account;
        private Race race;
        private Profession profession;
        private Int64 currentRoom;
        private List<Item> inventory;
        private List<Item> equipment;
        private Gender gender;
        private SecurityLevel securityLevel;

        public SecurityLevel SecurityLevel
        {
            get { return securityLevel; }
            set { securityLevel = value; }
        }

        public List<Item> Equipment
        {
            get { return equipment; }
            set { equipment = value; }
        }

        public List<Item> Inventory
        {
            get { return inventory; }
            set { inventory = value; }
        }

        public Gender Gender
        {
            get { return gender; }
            set { gender = value; }
        }

        public Room CurrentRoom
        {
            get 
            {
                return RoomUtilities.FindRoom(currentRoom);
            }
            set 
            { 
                currentRoom = value.RoomNumber; 
            }
        }

        public Profession Profession
        {
            get { return profession; }
            set { profession = value; }
        }

        public Race Race
        {
            get { return race; }
            set { race = value; }
        }

        [XmlIgnore]
        public Account Account
        {
            get { return account; }
            set { account = value; }
        }

        public String Name
        {
            get { return name; }
            set { name = value; }
        }

        public void Send(String message)
        {
            account.User.Send(String.Empty);
            account.User.Send(message);
            account.StandardPrompt();
        }

        public static void Send(Character character, String message)
        {
            foreach (User u in HammerMUD.System.HammerMUD.Users)
            {
                if (u.UserAccount.CurrentCharacter.Equals(character))
                {
                    u.Send(String.Empty);
                    u.Send(message);
                }
            }
        }

        internal void Move(Room room)
        {
            CurrentRoom.Characters.Remove(this);
            currentRoom = room.RoomNumber;
            room.Characters.Add(this);
        }
    }
}
